#include "p1.h"
#include <iostream>
#include <limits>


bool testHomeWork() {
    std::cout << "Enter a number: ";
    int x {};
    std::cin >> x;

    if (std::cin.fail()) {
        std::cin.clear(); // Clear error flag
        std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n'); // Ignore incorrect input left in the stream
        std::cout << "Invalid input. Please enter a valid number.\n";
    } else {
        std::cout << "You entered " << x << '\n';
    }

    // 清除输入之后的所有内容，以便安全地继续后续的输入操作
    std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');

    return true;
}


void testOperatorAndLiteral() {
    int x {2};
    std::cout << (x = 5) << '\n';
}


void myFirstFunc() {
    std::cout << " Please enter a number: ";
    int x {};
    std::cin >> x;
    std::cout << " Entered num is " << x << std::endl;
    std::cout << " Double num is " << x * 2 << std::endl;
    std::cout << " Triple num is " << x * 3 << std::endl;
}


void addAndSubstract() {
    int x {};
    int y {};
    std::cout << " Please enter a integer: ";
    std::cin >> x;
    std::cout << " Please enter another integer: ";
    std::cin >> y;

    std::cout << " " << x << " + " << y << " is " << x + y << std::endl;
    std::cout << " " << x << " - " << y << " is " << x - y << std::endl;
}
